﻿
namespace Project1
{
	/// <summary>
	/// Represents a point in two-dimensional space.
	/// </summary>
    struct Point2D : IPoint
    {
		/// <summary>
		/// The X coordinate.
		/// </summary>
        public int X;

		/// <summary>
		/// The Y coordinate.
		/// </summary>
		public int Y;

		/// <summary>
		/// Initializes a new instance of the <see cref="Point2D"/> struct.
		/// </summary>
		/// <param name="x">The X coordinate.</param>
		/// <param name="y">The Y coordinate.</param>
		public Point2D(int x, int y)
		{
			this.X = x;
			this.Y = y;
		}

		/// <summary>
		/// Determines whether the specified <see cref="System.Object"/> is equal to this instance.
		/// </summary>
		/// <param name="obj">The <see cref="System.Object"/> to compare with this instance.</param>
		/// <returns>
		///   <c>true</c> if the specified <see cref="System.Object"/> is equal to this instance; otherwise, <c>false</c>.
		/// </returns>
		public override bool Equals(object obj)
		{
			Point2D other = (Point2D)obj;
			return this.X == other.X && this.Y == other.Y;
		}

		/// <summary>
		/// Returns a hash code for this instance.
		/// </summary>
		/// <returns>
		/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. 
		/// </returns>
		public override int GetHashCode()
		{
			return ((long)this.X + (this.Y) * 5000).GetHashCode();
		}

		/// <summary>
		/// Returns a <see cref="System.String"/> that represents this instance.
		/// </summary>
		/// <returns>
		/// A <see cref="System.String"/> that represents this instance.
		/// </returns>
		public override string ToString()
		{
			return string.Format("({0},{1})", this.X, this.Y);
		}

		#region IPoint Members
		/// <summary>
		/// Gets an array with the coordinates of this point.
		/// </summary>
		/// <returns>
		/// An array of coordinates.
		/// </returns>
		int[] IPoint.GetDimensionalVector()
		{
			return new int[] {this.X, this.Y};
		}
		#endregion
	}
}
